<template>
  <d-list class="list-box" @load="$emit('getMoreData')" :finished="noMore" :showStatusText="false">
    <slot></slot>
    <div class="nodata" v-if="isEmpty && !loading">
      <img :src="image" alt="" style="width: 33%;">
      <p class="text">{{ text }}</p>
    </div>
    <template #status>
      <div class="loading">
        <div v-show="loading">
          <van-loading size="1.5rem">{{ loadingText }}</van-loading>
        </div>
      </div>
    </template>
  </d-list>
</template>
<script>
import DList from "@/components/dlist";
export default {
  components: { DList },
  props: {
    datas: {},
    text: {
      type: String,
      default: "暂无记录"
    },
    loading: {
      type: Boolean,
      default: false
    },
    loadingText: {
      type: String,
      default: "加载数据中..."
    },
    image: {
      type: String,
      default: require("../../../assets/images/empty-image-search.png")
    },
    noMore: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    isEmpty() {
      return !this.datas || this.datas.length <= 0
    }
  }
}
</script>
<style scoped lang="scss">
.list-box {
  .nodata {
    text-align: center;
    color: #999;
    line-height: 2.5rem;
    margin: 0.5rem 0;
  }

  .loading {
    width: 100%;
    height: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>